package util;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class Constant {
	public static final String FLOOR = "1";
	public static final String DINNER = "2";
	
	public static String sucResult(String strName){
		StringBuffer sb =new StringBuffer();
		sb.append("<script language='javascript'>");
		sb.append("alert('"+strName+"');");
		sb.append("</scri"+"pt>");
		return sb.toString();
	}
	public static String sucResultAndReturn(String strName,String url){
		StringBuffer sb =new StringBuffer();
		sb.append("<script language='javascript'>");
		sb.append("alert('"+strName+"');");
		sb.append("location.href='"+url+"'");
		sb.append("</scri"+"pt>");
		return sb.toString();
	}
	public static String sucReturn(String url){
		StringBuffer sb =new StringBuffer();
		sb.append("<script language='javascript'>");
		sb.append("location.href='"+url+"'");
		sb.append("</scri"+"pt>");
		return sb.toString();
	}
	//��String���н���
	public static String decodeString(String str)
	{
		String result = null;
		try {
			result = URLDecoder.decode(str, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}
	//�õ���ǰʱ��
	public static String decodeDate(){
		Date date = new Date(); 
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
		return sdf.format(date);
	}
	public static String decodeDateT(){
		Date date = new Date(); 
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
		return sdf.format(date);
	}
	public static String decodeDateTT(){
		Date date = new Date(); 
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 
		return sdf.format(date);
	}
	public static String getTableName()
	{
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String str = sdf.format(date);
		String month = str.substring(5, 7);
		String day = str.substring(8, 10);
		String lastStr = month+day;
		return lastStr;
	}
	public static String nullToString(String str){
		if(str==null){
			return "";
		}else{
			return str;
		}
	}
	/**
	 * 
	 *@author qingyu zhang
	 *@function:�õ�һ�����λ��
	 * @return
	 *Nov 25, 2010
	 *4:34:13 PM
	 *yxpsb
	 *com.psb.util
	 *String
	 */
	public static String getNum(){
		Random random = new Random();
		String rand="";
		for (int i=1;i<4;i++)
		{
		 rand+=String.valueOf(random.nextInt(10));
		}
		return rand;
	}
	public static String getNumT(){
		Random random = new Random();
		String rand="";
		for (int i=0;i<5;i++)
		{
			rand+=String.valueOf(random.nextInt(10));
		}
		return rand;
	}
	public static void main(String args[])
	{
		String ss = Constant.getTableName();
		System.out.println("ss="+ss);
	}
}
